package com.karina.visualization.chart.impl;

import gwt.g2d.client.graphics.Surface;

import com.google.gwt.user.client.ui.Widget;
import com.karina.visualization.chart.client.Context;
import com.karina.visualization.chart.client.Graphics;

public class CanvasContext implements Context {

	private final Surface canvas2 = new Surface();

	private final Graphics graphic = new CanvasGraphics(canvas2);

	@Override
	public Graphics getGraphics() {
		return graphic;
	}

	@Override
	public Widget getCanvasWidget() {
		return canvas2;
	}

	@Override
	public void setWidth(int width) {
		if (width == graphic.getCoordWidth())
			return;
		graphic.setCoordWidth(width);
	}

	@Override
	public void setHeight(int height) {
		if (height == graphic.getCoordHeight())
			return;
		graphic.setCoordHeight(height);
	}

	@Override
	public void setCoordinateXY(int i, int y) {
		graphic.translate(i, y);
	}
}
